import java.util.*;
public class Demo25{
        static int n;
        static int m;
        static int N = 300010;
        static int[] a = new int[N];
        static int[] s = new int[N];
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        n = scan.nextInt();m = scan.nextInt();

        List<Integer> alls = new ArrayList<>();
        List<Pair> add = new ArrayList<>();
        List<Pair> query = new ArrayList<>();

        for(int i = 0; i < n; i++){
            int x = scan.nextInt();
            int c = scan.nextInt();
            add.add(new Pair(x,c));
            alls.add(x);
        }
        for(int i = 0; i < m; i++){
            int l = scan.nextInt();
            int r = scan.nextInt();
            query.add(new Pair(l,r));
            alls.add(l);
            alls.add(r);
        }

        //去重
        Collections.sort(alls);
        int unique = unique(alls);
        alls = alls.subList(0,unique);

        for(Pair item: add){
            int index = find(item.first,alls);
            a[index] += item.second;
        }
        for(int i = 1; i <= alls.size(); i++)s[i] = s[i - 1] + a[i];

        for(Pair item: query){
            int l = find(item.first,alls);
            int r = find(item.second,alls);
            System.out.println(s[r] - s[l - 1]);
        }
    }
    public static int unique(List<Integer> list){
        int j = 0;
        for(int i = 0; i < list.size(); i++){
            if(i == 0 || list.get(i) != list.get(i - 1)){
                list.set(j,list.get(i));
                j++;
            }
        }
        return j;
    }
    public static int find(int x, List<Integer> list){
        //二分
        int l = 0;int r = list.size() - 1;
        while(l < r){
            int mid = l + r >> 1;
            if(list.get(mid) < x)l = mid + 1;
            else r = mid;
        }
        return l + 1;
    }
}

class Pair{
    int first;
    int second;
    public Pair(int x, int c){
        this.first = x;
        this.second = c;
    }
}